using UnityEngine;

public class EnemyState_幽魂_散步 : EnemyStateBase_幽魂
{
	private Vector2 _StartPos;

	private Vector2 _targetPos;

	private float _Speed = 1f;

	public float _Distance;

	public override void OnEnter()
	{
		_Mono._Ani.Play("移动");
		_StartPos = _Mono.transform.position;
		if (_StartPos.x < _Mono._StartPos.x)
		{
			_targetPos = _Mono._StartPos + new Vector2(6f, 0f);
		}
		else
		{
			_targetPos = _Mono._StartPos + new Vector2(-6f, 0f);
		}
		_Mono.transform.localScale = new Vector3((_targetPos.x < _StartPos.x) ? 1 : (-1), 1f, 1f);
		_Mono._Tsf_移动目标.transform.position = _targetPos;
		_Distance = Vector2.Distance(_StartPos, _targetPos);
		_Timer = 0f;
	}

	public override void OnExit()
	{
	}

	public override void OnUpdate()
	{
		if (_Mono._Is视野范围内)
		{
			_Mono.ChangeState(StateType_Enemy_幽魂.站立);
			return;
		}
		_Timer += Time.deltaTime * _Speed;
		Vector2 position;
		if (_Timer <= _Distance)
		{
			position = Vector2.Lerp(_StartPos, _targetPos, _Timer / _Distance);
		}
		else
		{
			position = _targetPos;
			_Mono.ChangeState(StateType_Enemy_幽魂.站立);
		}
		_Mono._Rb2D.MovePosition(position);
	}
}
